package com.idea.common.result;

import java.io.Serializable;

import com.idea.common.utils.ThreadLocalGson;

/**
 * @author xumin
 * @since 2012-5-17
 * 
 */
public class ResultBase implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 795272505141406466L;

	private boolean success = true;

	private String message = "";
	
	private String resultType = "ResultBase";
	
	public static ResultBase buildSuccessResult() {
		return new ResultBase();
	}

	public static ResultBase buildFailedResult(String message) {
		ResultBase result = new ResultBase();
		result.setSuccess(false);
		result.setMessage(message);
		return result;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public ResultBase setMessage(String message) {
		this.message = message;
		return this;
	}
	
	public String toJson(){
		return ThreadLocalGson.getGson().toJson(this);
	}
	
	
	
	@Override
	public String toString(){
		return toJson();
	}
	
	public String getResultType() {
		return resultType;
	}

	public void setResultType(String resultType) {
		this.resultType = resultType;
	}

	public static void main(String[] args) {
		System.out.println(ResultBase.buildFailedResult("test").toString());
	}
	
	
}
